#include "helper/object/std/StandardString.h"
#include <sstream>

namespace helper {
namespace object {

StandardString::StandardString()
: String()
{
}

StandardString::StandardString(const std::string & str)
: String()
, value_(str)
{
}
StandardString::StandardString(const char * str)
: String()
, value_(str)
{
}
StandardString::StandardString(const char * buffer, size_t offset, size_t len)
: String()
, value_(buffer, offset, len)
{
}
StandardString::StandardString(const char * buffer, size_t len)
: String()
, value_(buffer, len)
{
}
StandardString::StandardString(size_t n, const char ch)
: String()
, value_(n, ch)
{
}

StandardString::~StandardString(){
}

void StandardString::setValue(const std::string & value){
    if(value != this->value_){
        this->value_ = value;
    }
}
const std::string & StandardString::getValue() const{
    return value_;
}

size_t StandardString::size() const {
    return value_.size();
}

void StandardString::append(const std::string & str){
    value_ += str;
}
void StandardString::append(char ch){
    value_.push_back(ch);
}

std::string StandardString::toString() const{
    return "StandardString:" + value_;
}

bool StandardString::equals(const Object & obj) const {
    if(this != &obj){
        return obj.isString() && value_ == static_cast<const StandardString&>(obj).getValue();
    }
    return true;
}

Object * StandardString::copy() const {
    return new StandardString(value_);
}
void StandardString::clear() {
    return value_.clear();
}

} // end of namespace object
} // end of namespace helper
